Component({
  data: {
    selected: 0,
    color: "#AAA9A9",
    selectedColor: "#232323",
    list: [{
      pagePath: "/pages/index/index",
      //iconPath: "/image/icon_component.png",
      //selectedIconPath: "/image/icon_component_HL.png",
      text: "首页"
    }, {
      pagePath: "/pages/order/meal",
     // iconPath: "/image/icon_API.png",
      //selectedIconPath: "/image/icon_API_HL.png",
      text: "点单"
    },
    {
      pagePath: "/pages/take/meal",
     // iconPath: "/image/icon_API.png",
      //selectedIconPath: "/image/icon_API_HL.png",
      text: "取餐"
    },
    {
      pagePath: "/pages/my/index",
     // iconPath: "/image/icon_API.png",
      //selectedIconPath: "/image/icon_API_HL.png",
      text: "我的"
    }
  ]
  },
  attached() {
    console.log("attached");
 
  },
  ready(){
   this.setBottomTabColumnHeight();
  },
  onShow(){
    console.log("底部tab栏出来了");
  },
  methods: {
    async setBottomTabColumnHeight(){
      var getBottomTabColumnHeightRes=await this.getBottomTabColumnHeight();
      console.log("getBottomTabColumnHeightRes",getBottomTabColumnHeightRes);
      wx.setStorageSync('tabColumnHeight', getBottomTabColumnHeightRes.data)
    },
    //获取底部tab栏高度
  async getBottomTabColumnHeight(){
    var that=this;
    return new Promise((resolve)=>{
  
      const query = wx.createSelectorQuery().in(that)
      query.select('.tab-bar').boundingClientRect()
      query.selectViewport().scrollOffset();
      query.exec(function (res) {
          console.log("获取底部tab栏高度",res);
          var height=0;
          for(var i in res){
            if(res[i]){
                if(typeof(res[i].height)!="undefined"){
                  height=res[i].height;
                  break;
                }
            }
              if(res[i].height){
               // height=res[i].height;
                //break;
                
              }
          }
          resolve({code:"success",data:height})
      });
      
    });
  },
    switchTab(e) {
      const data = e.currentTarget.dataset
      const url = data.path
      wx.switchTab({url})
      this.setData({
        selected: data.index
      })
    }
  }
})